//封装购物车相关接口
import httpInstance from "@/utils/http"


//加入购物车
export const insertCartAPI = (skuId, count) => {
  return httpInstance.post('/member/cart', {
    skuId,
    count
  })
}

//获取购物车列表
export const findNewCartListAPI = () => {
  return httpInstance.get('/member/cart')
}

//删除购物车
export const delCartAPI = (ids) => {
  return httpInstance.delete('/member/cart', {
    data: {
      ids
    }
  })
}

//修改购物车商品
export const changeCartAPI = (skuId, selected, count) => {
  return httpInstance.put(`/member/cart/${skuId}`, {
    selected,
    count
  })
}

//购物车商品全选/取消功能
export const cartAllselectedAPI = (selected,ids) => {
  return httpInstance.put('/member/cart/selected',{
    selected,
    ids
  })
}

//合并购物车
export const mergeCartAPI = (array) => {
  return httpInstance.post('/member/cart/merge',
    array
  )
}
